package org.dizena.common.web;

import lombok.Data;

import java.io.Serializable;

@Data
public class ResultVO<T> implements Serializable
{
    private int code;

    private String msg;

    private T content;

    public ResultVO(int code, String msg)
    {
        this.code = code;
        this.msg = msg;
    }

    public static <T> ResultVO<T> success()
    {
        return new ResultVO<T>(200, "ok");
    }

    public static <T> ResultVO<T> success(T content)
    {
        ResultVO<T> vo = new ResultVO<T>(200, "ok");
        vo.setContent(content);
        return vo;
    }

    public static <T> ResultVO<T> fail(int code, String msg, T content)
    {
        ResultVO<T> vo = new ResultVO<T>(code, msg);
        vo.setContent(content);
        return vo;
    }

}
